package com.beiding.jsonanalyzer.querylink;

import com.beiding.jsonanalyzer.flow.Branch;
import com.beiding.jsonanalyzer.flow.BranchNode;
import com.beiding.jsonanalyzer.flow.ValueNode;

import java.util.function.Consumer;

public class EachBranchQueryLinkNode<W extends ValueNode> extends ComputeNode<W> {
    private Consumer<Branch<W>> branchConsumer;
    public EachBranchQueryLinkNode(QueryLinkNode<W> pre,Consumer<Branch<W>> branchConsumer) {
        super(pre);
        this.branchConsumer = branchConsumer;
    }

    @Override
    protected void bindByComputeNode(BranchNode<W> preResult, BranchNode<W> newBranchNode) {
        branchConsumer.accept(newBranchNode.getBranch());
        ComputeNodeUtils.bindControlEvent(preResult, newBranchNode);
        ComputeNodeUtils.bindDataEvent(preResult, newBranchNode);

    }
}
